//
//  DefaultScene.h
//  Ray Tracer
//
//  Created by Kaila, Ashish on 4/1/13.
//  Copyright (c) 2013 Kaila, Ashish. All rights reserved.
//

#ifndef Ray_Tracer_DefaultScene_h
#define Ray_Tracer_DefaultScene_h

void renderDefaultScene(Raytracer& raytracer,
                        int width,
                        int height,
                        bool enableSpecular)
{
    // Camera parameters.
	Point3D eye(0, 0, 1);
	Vector3D view(0, 0, -1);
	Vector3D up(0, 1, 0);
	double fov = 60;
    
	// Defines a material for shading.
	SolidMaterial gold( Colour(0.3, 0.3, 0.3), Colour(0.75164, 0.60648, 0.22648),
                       Colour(0.628281, 0.555802, 0.366065),
                       51.2,
                       0,
                       0,
                       0);
    
	SolidMaterial jade( Colour(0, 0, 0), Colour(0.54, 0.89, 0.63),
                       Colour(0.316228, 0.316228, 0.316228),
                       12.8,
                       0,
                       0,
                       0);
    
	// Defines a point light source.
	raytracer.addLightSource( new PointLight(Point3D(0, 0, 5),
                                             Colour(0.9, 0.9, 0.9) ),
                             enableSpecular);
    
	// Add a unit square into the scene with material mat.
	SceneDagNode* sphere = raytracer.addObject( new UnitSphere(&gold));
	SceneDagNode* plane = raytracer.addObject( new UnitSquare(&jade));
	
	// Apply some transformations to the unit square.
	double factor1[3] = { 1.0, 2.0, 1.0 };
	double factor2[3] = { 6.0, 6.0, 6.0 };
    SceneObject* sphereObj = sphere->obj;
	sphereObj->translate(Vector3D(0, 0, -5));
	sphereObj->rotate('x', -45);
	sphereObj->rotate('z', 45);
	sphereObj->scale(Point3D(0, 0, 0), factor1);
    
    SceneObject* planeObj = plane->obj;
	planeObj->translate(Vector3D(0, 0, -7));
	planeObj->rotate('z', 45);
	planeObj->scale(Point3D(0, 0, 0), factor2);
    
	// Render the scene, feel free to make the image smaller for
	// testing purposes.
	raytracer.render(width, height, eye, view, up, fov, "view1.bmp");
	
	// Render it from a different point of view.
    Point3D eye2(4, 2, 1);
	Vector3D view2(-4, -2, -6);
	raytracer.render(width, height, eye2, view2, up, fov, "view2.bmp");
}

#endif
